package com.pet.server.dao.common;

import java.util.List;
import com.pet.framework.dao.util.TemplateDao;
import com.pet.framework.page.Page;
import com.pet.server.po.Campaign;
import com.pet.server.po.CateBrand;
import com.pet.system.statement.Statement;
public class AdminDao extends TemplateDao {
	
    public boolean haveUser(String username){    	
		Statement stms = stmsFactory.createStatement(" from UserInfo u where u.userName=?");
		          stms.addParam(username);
    	return templateDao.query(stms).iterator().hasNext();
	}
    public List<CateBrand> queryCateBrand(String cate){
		Statement stms = stmsFactory.createStatement(" from CateBrand c where c.cate=?");
		          stms.addParam(cate);
		return templateDao.query(stms);
    }
    public void deleteCateBrandByCate(String cate){
    	Statement stms = stmsFactory.createStatement(" delete CateBrand c where c.cate=?");
                  stms.addParam(cate);
        templateDao.update(stms);
    }
    
    /**
     * 活动列表
     * @param campaign
     * @param page
     */
	public void searchCampaign(Campaign campaign, Page page) {
		Statement stms = stmsFactory.createStatement(" from Campaign p where 1=1 and  state!=4");
		 if(null!=campaign){
	     	  stms.append("and", "p.click_type", "=", campaign.getClickType());
	      }
         stms.addOrderBy("p.id desc");
         templateDao.search(stms, page);	
	}
    
}
